<?php
defined('IN_CMS') or exit('No permission resources.');
pc_base::load_app_class('admin','admin',0);
pc_base::load_sys_class('form','',0);
class education extends admin  {
	function __construct() {
        parent::__construct();
		$this->dbBaseContent = pc_base::load_model("mybasecontent_model");
		$this->db = pc_base::load_model("myeducation_model");
	}
	
	/**
	 * 列表
	 */
	function mylist(){
		$userId = $_GET['user_id'];
		$page = isset($_GET['page']) && intval($_GET['page']) ? intval($_GET['page']) : 1;
        switch ($_POST['action']){
            case "add":
                $item = $_POST['item'];
                $item['last_updated_time'] = $this->CURRENT_DATETIME;
                $item['created_time'] = $this->CURRENT_DATETIME;
                $item['user_id'] = $userId;
                $id = $this->db->insert($item,true);
                break;
            case "edit":
                $id = $_POST['id'];
                $item = $_POST['item'];
                $item['last_updated_time'] = $this->CURRENT_DATETIME;
                $this->db->update($item,$where = 'id = '.$id);
                break;
        }

        $whereSql = ' is_del=0';
        $lists = $this->db->listinfo($whereSql,$order = 'id DESC',$page);
        $pages = $this->db->pages;

        $stateDesc = array(
        	'1'=>'在职',
        	'2'=>'离职',
        	'3'=>'应届生'
        );
        
		include $this->admin_tpl('myeducation_list');
	}
	
	
	function myadd(){
		$companyId = $_GET['company_id'];
		include $this->admin_tpl('myeducation_add');
		
	}
	
	function myedit(){
		$id = $_GET['id'];
		$whereSql = array('id'=>$id);
		$item = $this->db->get_one($whereSql);
		
		include $this->admin_tpl('myeducation_edit');
	}

	function mycheckone(){
		$id = $_GET['id'];
		$new['is_show'] = 1;
		$this->db->update($new,$where = 'id = '.$id);
		$this->mylist();
	}
	
	function myview(){
        $jobTypeDesc = array(
        	'1'=>'全职',
        	'2'=>'兼职',
        	'3'=>'全职或者兼职'	
        );
		$id = $_GET['id'];
		$userId = $_GET['user_id'];
		$whereSql = "id = '" . $id . "'";
        $item = $this->db->get_one($whereSql);

		include $this->admin_tpl('myeducation_view');
	}
	
	
	function mydelone(){
		$id = $_GET['id'];
		$new['is_del'] = 1;
		$this->db->update($new,$where = 'id = '.$id);
		$this->mylist();
	}
	
	/**
	 * 批量删除
	 */
	function mydel(){
		$ids = $_POST['id'];
		
		if(empty($ids) || !is_array($ids)){
			showmessage(L('没有记录可以删除'),HTTP_REFERER);
		}else{
			foreach ($ids as $id){
				$new['is_del'] = 1;
				$this->db->update($new,$where = 'id = '.$id);
			}
		}
		$this->mylist();
	}

	/**
	 * 批量审核
	 */
	function mycheck(){
		$ids = $_POST['id'];
		
		if(empty($ids) || !is_array($ids)){
			showmessage(L('没有记录可以审核'),HTTP_REFERER);
		}else{
			foreach ($ids as $id){
				$new['is_show'] = 1;
				$this->db->update($new,$where = 'id = '.$id);
			}
		}
		$this->mylist();
	}

}

?>